<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>团队互助记录</title>
    <link rel="stylesheet" type="text/css" href="<?=base_url()?>public/css/style.css">
    <script type="text/javascript" src="<?=base_url()?>public/js/jq.1.12.4.js"></script>
    <script type="text/javascript" src="<?=base_url()?>public/js/js.js"></script>
<style type="text/css">
	td{
		cursor:default;
	}


#page{height:32px;line-height:32px;margin-top:15px;margin-bottom:15px;text-align:left;}
#page a{background:#fff;border-radius:5px;float:left;display:block;padding:0 12px;line-height:32px;border:1px solid #ddd;margin-right:5px;font-size:12px;font-weight:bold;color:#444;}
#page a:hover{background:#f6f6f6}
#page a.cur{color:red;background:#444;border:1px solid #444;color:#fff;}
#page a.noborder{border:none;margin:0 2px;}


</style>
</head>
<body>
	<!-- 头部 -->
	<?php echo $menu ?>
	<!-- 主体 -->
	<div class="main clearfix">
		<?php echo $left ?>
		<div class="content">
			<div class="con">
				<div class="bikuang">
                	<div class="right_title"><span>公益团队中心&nbsp;&nbsp; -<span style="color:#1d3e00; margin:0;">&nbsp;&nbsp;团队合作记录</span></span></div>  
                    	<div class="table">
                        	<table cellpadding="0" cellspacing="0">
                            	<tr>
                                	<th>公益账号</th>
                                    <th>姓名</th>
                                    <th>合作金额</th>
                                    <th style='width:300px;'>匹配时间</th>
                                    <th style='width:230px;'>状态</th>
									<th>合作接单</th>
                                    <th>推广人账号</th>
									<th>推广人姓名</th>
                                </tr>
                                <?php foreach($data_list as $key => $datalist){ ?>
                                <tr class="er">
                                	<td><?php echo $datalist['user_account'] ?></td>
                                    <td><?php echo $datalist['user_name'] ?></td>
                                    <td><?php echo $datalist['money'] ?></td>
                                    <td style='width:300px;'><?php  if($datalist['pipei_time'] != 0):?>
                                        <?php echo date('Y-m-d H:i:s',$datalist['pipei_time']) ?>
                                        <?php else: ?>
                                        未匹配
                                        <?php endif; ?>
                                    </td>
                                    <td class="zhuangtai"  style='  width:230px;'>
                                        <?php $wait_time = 0; $has_time =  0; ?>
                                        
                                        <?php if($datalist['pay_status'] == 2):?>
                                        拒绝打款<br>
                                        <?php
                                         
                                         $wait_time = 0;
                                         $has_time = 14400 - ( time() - $datalist['pay_time']);
                                         if($has_time > 0){
                                            echo "接单倒计时：";
                                        }
                                        ?>
                                        <?php elseif($datalist['dakuan'] == 1 && $datalist['shoukuan'] == '0'):?>
                                       匹配， 已打款<br>
									   <?php elseif($datalist['pay_status'] == 0 && $datalist['pipei_time'] != 0): ?>
                                        匹配，未打款<br>
                                        <?php 
                                            //echo date('Y-m-d H:i:s',$datalist['pipei_time']); 

                                            $atime = time() - $datalist['pipei_time'];

                                            if($atime < 86400){
                                                //等待时间
                                                $wait_time = 86400 - $atime;
                                                //接单时间
                                                $has_time = 0;
                                            }else{

                                                $has_time = 0;

                                                $has_time = 86400 + 14400 - $atime;
                                            }


                                        ?>
									    <?php elseif($datalist['pay_status'] == 1 && $datalist['shoukuan'] == '1'):?>
                                       匹配， 已确认收款<br>
                                        
                                        <?php else: ?>
                                        未匹配
                                        <?php endif; ?>
                                        <?php 
                                        if($wait_time > 0){
                                            $str_time = $wait_time;
                                         }else if($has_time > 0){
                                            $str_time = $has_time;
                                         }else{
                                            $str_time = 0;
                                         }
                                        //echo $str_time; 
                                         if($str_time > 0){
                                            echo '<span class="settime" endTime="'.$str_time .'"></span>';
                                        }else{
                                            echo '';
                                        }
                                        ?>
                                    </td>
									<td>
                                    <?php if($datalist['up_user_id'] == -1): ?>
                                    <?php echo '已拒绝' ?>
                                    <?php elseif( ($datalist['pay_status'] == 2 && $has_time > 0) ||  ($datalist['pay_status'] == 0 && $has_time >0) ): ?>
                                        <?php if($user['user_account'] == $datalist['up_account']): ?>
                                            <p class="btn_on"><a href="<?php echo site_url('team_log/info_post/1/').$datalist['id'] .'/'.$user['id'].'/'.$datalist['money']?>">接单</a></p>
                                            <p class="btn_off"><a href="<?php echo site_url('team_log/info_post/-1/').$datalist['id'] .'/'.$user['id'].'/'.$datalist['money']?>">拒绝</a></p>
                                        <?php endif; ?>
                                    <?php elseif(($datalist['pay_status'] == 2 && $has_time < 0) ||  ($datalist['pay_status'] == 0 && $has_time <0)): ?>
                                        <?php echo '过期'; ?>
                                    <?php endif; ?>
                                    </td>
                                    <td><?php echo $datalist['up_account'] ?></td>
									 <td><?php echo $datalist['up_name'] ?></td>
                                </tr>
                                <?php } ?>
                            </table>
                            <?php echo $multi;?>
                    </div>
				</div>
			</div>
		</div>
	</div>

</body>
</html>
<script type="text/javascript">
$(function(){

        updateEndTime();
        $('.btn_chakan').on('click', function(event) {
            $($(this).next()).show();
        });
    });
    //遍历倒计时
    function updateEndTime(){
        $(".settime").each(function(i){
            var lag = this.getAttribute("endTime");//(endTime - time) / 1000; //当前时间和结束时间之间的秒数
            $(this).attr("endTime",lag-1);
            if(lag > 0)
            {
                var time_str = '';
                if(lag > 86400){
                    time_str += Math.floor((lag / 3600) / 24)+'天';
                     console.log(time_str);
                }
                if(lag >3600){
                    time_str += Math.floor((lag / 3600) % 24)+"小时";
                     console.log(time_str);
                }
                if(lag > 60)
                {
                    time_str += Math.floor((lag / 60) % 60)+"分";
                     console.log(time_str);
                }
                if(lag > 0)
                {
                    time_str += Math.floor(lag % 60)+"秒";
                     console.log(time_str);
                }

                $(this).html(time_str);
            }
            else{
                $(this).removeClass("settime");
                $(this).html("已过期");
            }
        });
        setTimeout("updateEndTime()",1000);
    }
</script>
